home *** CD-ROM | disk | FTP | other *** search
/ The PC-SIG Library 10 / The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso / PC_SIGCD / 22 / 4 / DISK2247.ZIP / CBASE101.ZIP / CBASE.ZIP / CBRECLAS.C < prev    next >
Text File  |  1990-06-21  |  2KB  |  80 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbreclas.c    1.4 - 90/06/20" */
  5.  
  6. /* ansi headers */
  7. #include <errno.h>
  8.  
  9. /* library headers */
  10. #include <lseq.h>
  11.  
  12. /* local headers */
  13. #include "cbase_.h"
  14.  
  15. /*man---------------------------------------------------------------------------
  16. NAME
  17.      cbreclast - last cbase record
  18.  
  19. SYNOPSIS
  20.      #include <cbase.h>
  21.  
  22.      int cbreclast(cbp)
  23.      cbase_t *cbp;
  24.  
  25. DESCRIPTION
  26.      The cbreclast function positions the record cursor of cbase cbp
  27.      on the last record.
  28.  
  29.      cbreclast will fail if one or more of the following is true:
  30.  
  31.      [EINVAL]       cbp is not a valid cbase pointer.
  32.      [CBELOCK]      cbp is not locked.
  33.      [CBENOPEN]     cbp is not open.
  34.      [CBENREC]      cbp is empty.
  35.  
  36. SEE ALSO
  37.      cbreccnt, cbrecfirst, cbrecnext, cbrecprev.
  38.  
  39. DIAGNOSTICS
  40.      Upon successful completion, a value of 0 is returned.  Otherwise,
  41.      a value of -1 is returned, and errno set to indicate the error.
  42.  
  43. ------------------------------------------------------------------------------*/
  44. int cbreclast(cbp)
  45. cbase_t *cbp;
  46. {
  47.     /* validate arguments */
  48.     if (!cb_valid(cbp)) {
  49.         errno = EINVAL;
  50.         return -1;
  51.     }
  52.  
  53.     /* check if not open */
  54.     if (!(cbp->flags & CBOPEN)) {
  55.         errno = CBENOPEN;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not locked */
  60.     if (!(cbp->flags & CBLOCKS)) {
  61.         errno = CBELOCK;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if cbp is empty */
  66.     if (lsreccnt(cbp->lsp) == 0) {
  67.         errno = CBENREC;
  68.         return -1;
  69.     }
  70.  
  71.     /* set cursor to last record */
  72.     if (lslast(cbp->lsp) == -1) {
  73.         CBEPRINT;
  74.         return -1;
  75.     }
  76.  
  77.     errno = 0;
  78.     return 0;
  79. }
  80.